package com.ryan.pintu;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class BitMapUtility {

    public static Bitmap rotate90(Bitmap b) {
        if ( b != null) {
            Matrix m = new Matrix();
//            m.setRotate(-90);
            m.postRotate(-90);
            
//            m.setRotate(degrees,
//                    (float) b.getWidth() / 2, (float) b.getHeight() / 2);
            try {
                Bitmap b2 = Bitmap.createBitmap(
                        b, 0, 0, b.getWidth(), b.getHeight(), m, true);
                if (b != b2) {
                    b.recycle();  
                    b = b2;
                }
            } catch (OutOfMemoryError ex) {
                ex.printStackTrace();
            }
        }
        return b;
    }
}
